<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .grid-container {
            display: grid;
            grid-template-columns: auto auto auto auto;
            grid-gap: 10px;
            background-color:#fff;
            padding: 10px;
            width: 600px;
            height:400px;
        }
        .grid-container > div {
            background-color: rgba(255, 255, 255, 0.8);
            text-align: center;
            padding: 20px 0;
            font-size: 30px;
            width: 600px;
            height:400px;
        }
    </style>
</head>
<body>
<!--&lt;!&ndash; 为 ECharts 准备一个定义了宽高的 DOM &ndash;&gt;-->
<!--<div id="main" style="width: 600px;height:400px;"></div>-->
<!--<div id="main1" style="width: 600px;height:400px;"></div>-->
<div class="grid-container">
    <div class="item1" id="main"></div>
    <div class="item1" id="main1"></div>
    <div class="item1" id="main2"></div>
</div>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/echarts@5.5.0/dist/echarts.min.js"></script>
<script>
    $(function(){
        $.ajax({
            url:'php/tb.php',
            success(res){
                console.log(res.data)
                Chart1(res.data.x,res.data.y)
                Chart2(res.data.bt)
                CHart3(res.data.zx,res.data.zx1)
            },
            error(){
                alert('请求失败')
            }
        })
    });
</script>
<script type="text/javascript">
    function Chart1(x,y) {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));

        // 指定图表的配置项和数据
        var option = {
            title: {
                text: 'ECharts 入门示例'
            },
            tooltip: {},
            legend: {
                data: ['人数']
            },
            xAxis: {
                data: x
            },
            yAxis: {},
            series: [
                {
                    name: '人数',
                    type: 'bar',
                    data: y
                }
            ]
        };

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    }
    function Chart2(bt) {
        var chartDom = document.getElementById('main1');
        var myChart = echarts.init(chartDom);
        var option;

        option = {
            title: {
                text: 'Referer of a Website',
                subtext: 'Fake Data',
                left: 'center'
            },
            tooltip: {
                trigger: 'item'
            },
            legend: {
                orient: 'vertical',
                left: 'left'
            },
            series: [
                {
                    name: 'Access From',
                    type: 'pie',
                    radius: '50%',
                    data: bt,
                    emphasis: {
                        itemStyle: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]
        };

        option && myChart.setOption(option);

    }
    function CHart3(zx,zx1) {
        var chartDom = document.getElementById('main2');
        var myChart = echarts.init(chartDom);
        var option;

        option = {
            xAxis: {
                type: 'category',
                data: zx1
            },
            yAxis: {
                type: 'value'
            },
            series: [
                {
                    data: zx,
                    type: 'line'
                }
            ]
        };

        option && myChart.setOption(option);
    }
</script>
</body>
</html>